import React, { Component, createRef } from "react"


// class App extends Component {

//         state = {
//             name: 'React',
//             isLiked: false
//             }
//         // 方法
//         testa (){
//             console.log('testa')
//         }


//         render (){
//             return (
//                 <h2>{this.state.name}</h2>
//             )
//         }
//     }
class App extends Component {
    constructor() {
        super()
        this.state = {
            name: 'React',
            isLiked: false
        }
    }

    // 方法
    testa() {
        console.log(123)
        this.setState({
          name: 'Vue'  
        })
    }
    inputRef = React.createRef()

    render() {
        return (
            <div>   
                    <input ref={this.inputRef}></input>
                    <button onClick={()=>{ console.log(this.inputRef.current.value)}}>get</button>
                    <h2>{this.state.name}</h2>
                    <button onClick={this.testa.bind(this)}> edit </button>
            </div>
            
        )
    }
}
export default App;